package cb.ex;

/**
 * @author wzby
 * @Date: 2022/7/30 11:30
 */
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Ex1 {
    public static void main(String[] args) {
        Set<Integer> set = new HashSet<>();
        set.addAll(List.of(1, 2, 3, 2, 3, 4, 5, 5, 5, 5, 6));
        System.out.println(set.size());
        System.out.println(set);
        //set.clear();
        System.out.println(set.add(3));//false

        System.out.println(set.contains(3));//true
        System.out.println(set.contains(3L));//false

        //set.clear();
        if(set.contains(3)){
            System.out.println(set.remove(3));//true
            System.out.println(set.remove(3));//false
        }

        System.out.println(set);

        System.out.println(set.removeAll(List.of(11, 22, 55)));

        System.out.println(set);

        //[1,2,3] - [3,5,6]  = [1,2] 差


        //[1,2,3] + [3,5,6]  = [1,2,3,5,6] 并
        //交集 [1,2,3] 交集操作 [3,5,6,2] = [3,2]

    }
}